
_ = require 'underscore'
ViewContentHandler = require '../helpers/view_content_handler'
HttpHandler = require '../../../helpers/http_handler'
ViewDataHandler = require '../models/view_data_handler'

###*
 * [homePageHandle description]
 * @param  {[type]}   req  [description]
 * @param  {[type]}   res  [description]
 * @param  {Function} next [description]
 * @return {[type]}        [description]
###
homePageHandle = (req, res, next) ->
  ViewDataHandler.home (err, data) ->
    if err
      res.render 'error', 504
    else
      view = 'vicanso/home'
      renderData = ViewContentHandler.home req, view, '每天再往前一点！', 0, data
      HttpHandler.renderAndCache req, res, view, renderData


module.exports = homePageHandle

